package Zoo;

abstract class Employee {
    protected String name;
    protected double salary;

    public Employee(String name,double salary) {
        this.name=name;
        this.salary=salary;
    }

    public abstract double calculateSalary();
}
class SalariedEmployee extends Employee {
    public SalariedEmployee(String name,double salary) {
        super(name, salary);
    }

    @Override
    public double calculateSalary() {
        return salary;
    }
}
class HourlyEmployee extends Employee {
    private double hourlyRate;
    private double hourlyWorked;

    public HourlyEmployee(String name,double hourlyRate,double hourlyWorked) {
        super(name,0);
        this.hourlyRate=hourlyRate;
        this.hourlyWorked=hourlyWorked;
    }
     @Override
    public double calculateSalary() {
        return hourlyRate * hourlyWorked;
     }
}
public class Money {
    public static void main(String[] args) {
        Employee[] employees = new Employee[6];
        for(int i=0;i<employees.length;i++) {
            if(Math.random() < 0.5) {
                employees[i] = new SalariedEmployee("Salaried Employee "+i,3000);
            } else {
                employees[i] = new HourlyEmployee("Hourly Employee "+i,20,160);
            }
        }
        for(Employee employee : employees) {
            System.out.println(employee.name + "'s salary is: "+employee.calculateSalary());
        }
    }
}
